import { http } from '@/utils/http'
import type { promises } from 'dns'
//我的认证的数据列表接口
export interface listData {
  url: string
  text: string
  path: string
  flag?: any
}
//我的足迹的数据列表接口
export interface blindData {
  url: string
  text: string
}
// 我的相亲数据列表类型接口
export interface MyBlindDatelist {
  url: any
  text: string
  path: string
}

interface phoneComfirmType {
  id: string //用户id
  phone: string //手机号
  code: string //验证码
}
interface sendCodeType {
  id: string //用户id
  phone: string //手机号
}
interface RealInfoType {
  id: string //用户id
  realName: string //真实姓名
  IDCode: string //身份证号
}
interface ConfirmType {
  id: string //用户id
  diplomaImage?: string //毕业证认证图片
  carImage?: string //行驶证认证图片
  houseImage?: string //房产证认证图片
  salaryImage?: string //工资流水认证图片
}
export interface confirmData {
  realName?: string //真实姓名
  IDCode?: string //身份证号
  carImage?: string //行驶证
  phone?: string //手机号
  diplomaImage?: string //学历证
  houseImage?: string //房产证
  salaryImage?: string //工资流水
}
//签到的数据列表接口
interface SignInResponse {
  msg: string
  code: number
  coins: number
}
interface GetMoneyResponse {
  msg: string
  code: number
  coins: number
}
interface GetLoveResponse {
  code: number
  data: any
}

interface GetDetailResponse {
  msg: string
  code: number
  data: Array<{
    id: string
    user_id: string
    source: string
    amount: number
    details_in_date: Date // 假设这是一个日期字符串，根据实际情况调整类型
  }>
}

export const signupAPI = (userId: string): promises<SignInResponse> => {
  return http<SignInResponse>({
    method: 'POST',
    url: '/get/api/v1/develop/signup',
    header: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: {
      id: userId,
      source: '每日签到(小程序)',
    },
  })
}

export const getMoneyAPI = (userId: string): promises<GetMoneyResponse> => {
  return http<GetMoneyResponse>({
    method: 'GET',
    url: '/get/api/v1/develop/getconins',
    data: {
      id: userId,
    },
  })
}

// 获取头像
export const getAvatarAPI = (): promises<GetMoneyResponse> => {
  return http<GetMoneyResponse>({
    method: 'GET',
    url: '/get/api/v1/develop/avatar',
    data: {
      u_id: uni.getStorageSync('userInfo').id,
    },
  })
}

export const getLoveyAPI = (LovesId: string): promises<GetLoveResponse> => {
  return http<GetLoveResponse>({
    method: 'GET',
    url: '/get/api/v1/develop/like/get-like-attention',
    data: {
      user_id: LovesId,
    },
  })
}

export const getpercentageAPI = (percentageId: string): promises<GetLoveResponse> => {
  return http<GetLoveResponse>({
    method: 'GET',
    url: '/get/api/v1/develop/percentage',
    data: {
      my_id: percentageId,
    },
  })
}
export const getDetailAPI = (userId: string): promises<GetDetailResponse> => {
  return http<GetDetailResponse>({
    method: 'GET',
    url: '/get/api/v1/develop/getdetails',
    data: {
      id: userId,
    },
  })
}
//获取用户认证信息接口
export const getUserInfoAPI = (id: string) => {
  return http({
    method: 'GET',
    url: '/get/api/v1/develop/authentication',
    data: {
      id: id,
    },
  })
}
//修改手机认证接口
export const postPhoneComfirmAPI = (data: phoneComfirmType) => {
  return http({
    method: 'POST',
    url: '/get/api/v1/develop/authentication',
    header: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data,
  })
}
//发送验证码接口
export const postSendCodePhoneAPI = (data: sendCodeType) => {
  return http({
    method: 'POST',
    url: '/get/api/v1/develop/sendCode',
    header: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data,
  })
}
//修改实名认证接口
export const postRealInfoAPI = (data: RealInfoType) => {
  return http({
    method: 'POST',
    url: '/post/api/v1/develop/realInfo',
    header: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data,
  })
}

//修改实名认证接口
export const ConfirmAPI = (data: ConfirmType) => {
  return http({
    method: 'POST',
    url: '/post/api/v1/develop/ConfirmAPI',
    header: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data,
  })
}
// 修改数据接口
export const postUpdateDataAPI = (data: any) => {
  return http({
    method: 'POST',
    url: '/post/api/v1/develop/change-user',
    data,
  })
}
// 获取用户信息，并回填数据
export const getUserAPI = (my_id: string) => {
  return http({
    method: 'GET',
    url: '/get/api/v1/develop/seek/information',
    data: {
      my_id: my_id,
    },
  })
}
